{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑收货地址</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">收货人：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" lay-verify="required" value="{$address.addr_username}" name="addr_username">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">手机号：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" lay-verify="required" value="{$address.addr_phone}" name="addr_phone">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md12">
                            <label class="layui-form-label">地址：</label>

                            <div class="layui-input-inline" style="margin-top: 5px">
                                <select name="addr_sheng" lay-search="" lay-verify="required" id="province"  lay-filter="province">
                                    {foreach name="province" item="vo"}
                                    <option value="{$vo.district_id}" {$address.addr_sheng == $vo.district_id ? 'selected' : ''}>{$vo.district}</option>
                                    {/foreach}
                                </select>
                            </div>

                            <div class="layui-input-inline" style="margin-top: 5px">
                                <select name="addr_shi" lay-search="" lay-verify="required"  id="city"  lay-filter="city">
                                    {foreach name="city" item="vo1"}
                                    <option value="{$vo1.district_id}" {$address.addr_shi == $vo1.district_id ? 'selected' : ''}>{$vo1.district}</option>
                                    {/foreach}
                                </select>
                            </div>

                            <div class="layui-input-inline" style="margin-top: 5px">
                                <select name="addr_qu" lay-search="" lay-verify="required"  id="district"  lay-filter="district">
                                    {foreach name="qu" item="vo2"}
                                    <option value="{$vo2.district_id}" {$address.addr_qu == $vo2.district_id ? 'selected' : ''}>{$vo2.district}</option>
                                    {/foreach}
                                </select>
                            </div>

                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">详细地址：</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" lay-verify="required" value="{$address.addr_address}" name="addr_address">
                            </div>
                        </div>

                        <input type="hidden" value="{$addr_id}" name="addr_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">确定
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
</body>
</html>
<script type="text/javascript">
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('addressUpdate')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        });
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>